package engine.tip.tipItem
{
	import engine.data.ObjectData;
	import engine.data.RoleVo;
	import engine.data.ViewObject;
	import engine.newUi.DetailPropertyLogic;
	import engine.newUi.DoMarrowLogic;
	import engine.tip.TipsMainLogic;
	import engine.tip.TipsPanelUI;
	
	import newx.com.config.StaticIni;

	/**
	 *洗髓 （tips字符串空壳）
	 * @author yanghr
	 * 
	 */	
	public class MarrowItem implements ITipItem
	{
		private var serverArr:Array;
		private var serverobj:Object;
		private var lvl:int;
		public static function checkInt(propertyName:String):Boolean
		{
			return !StaticIni.getIniObj("PercentMap").hasOwnProperty(propertyName);
		}
		public function MarrowItem(dataObj:ObjectData,lvl:int)
		{
			serverArr=DoMarrowLogic.getInstance().serverArr;
			this.dataObj=dataObj;
			this.data=lvl;
		}
		private var mainDataobj:ObjectData;
		/**
		 *伙伴或者  主角 
		 * @param value
		 * 
		 */		
		public function set dataObj(value:ObjectData):void
		{
			mainDataobj=value;
		}
		
		public function set panel(value:TipsPanelUI):void
		{
			throw new Error("不能被用于显示没用！！！！")
		}
		
		public function buildTip():void
		{
		}
		/**
		 *等级 （int）
		 * @param value
		 * 
		 */		
		public function set data(value:Object):void
		{
			lvl=int(value);
			var	pos:int	=	mainDataobj is RoleVo?-1:int(mainDataobj.ObjKey);
			serverobj=serverArr[pos];
			if(!DoMarrowLogic.getInstance().checkServerObj(mainDataobj,pos)&&lvl>0)
			{
				DoMarrowLogic.getInstance().requestForServerobj(lvl,pos);
			}
		}
		
		public function  getWashMainStr():String
		{
			if(!serverobj||!serverobj.hasOwnProperty(lvl))
			{
				return "";
			}
			var propertiesName:Array=getPropertiesColorArr();
			var lvlStr:String=getName();
			return 	StaticIni.getSwfLangStrVar("RandomPropertyTips_11",[lvlStr,propertiesName[0],propertiesName[1],propertiesName[2]])//={@0:当前阶段名}：<br/>{@1:属性1字段}<br/>{@2:属性2字段}<br/>{@3:属性3字段}
		}
		/**
		 *当前阶段名 
		 * @return 
		 * 
		 */		
		public function getName():String
		{
			return StaticIni.getSwfLangStr("RandomPropertyTips_"+lvl)
		}
		public function getPropertiesColorArr():Array
		{
			var properties:Object=StaticIni.getIniObj("PropertyRank"+lvl);
			var propertiesName:Array=[];
			propertiesName["data"]={};
			propertiesName["index"]=[];
			for (var j:String in properties) 
			{
				if(!serverobj||!serverobj.hasOwnProperty(lvl))
					return null;
				var num:Number=serverobj[lvl][j][0];
				var numS:String=DetailPropertyLogic.getInstance().outZero(num.toFixed(2));
				var obj:Object=DoMarrowLogic.getInstance().findQualityPoint(lvl,j,num)
				var color:int=obj[2];
				propertiesName[propertiesName.length]=TipsMainLogic.instance.getColorHtml(StaticIni.getSwfLangStrVar("Item_"+j,[numS]),DoMarrowLogic.getInstance().QUALITY_ARR[color]);
				propertiesName["data"][j]=num;
				propertiesName["index"].push(j);
			}
			return propertiesName
		}
	}
}